<?php
/**
 * LICENSE
 * 
 * [license information]
 * 
 * @category   Nine
 * @copyright  Copyright (c) 2009 visualidea.org
 * @license    http://license.visualidea.org
 * @version    v 1.0 2009-04-15
 */
require_once 'Nine/Model.php';
class Models_BKCardCategory extends Nine_Model
{ 
    /**
     * The primary key column or columns.
     * A compound key should be declared as an array.
     * You may declare a single-column primary key
     * as a string.
     *
     * @var mixed
     */
    protected $_primary = 'bkcard_category_id';
    
    /**
     * Constructor.
     *
     * Supported params for $config are:
     * - db              = user-supplied instance of database connector,
     *                     or key name of registry instance.
     * - name            = table name.
     * - primary         = string or array of primary key(s).
     * - rowClass        = row class name.
     * - rowsetClass     = rowset class name.
     * - referenceMap    = array structure to declare relationship
     *                     to parent tables.
     * - dependentTables = array of child tables.
     * - metadataCache   = cache for information from adapter describeTable().
     *
     * @param  mixed $config Array of user-specified config options, or just the Db Adapter.
     * @return void
     */
    public function __construct($config = array())
    {
        $this->_name = $this->_prefix . 'bkcard_category';
        return parent::__construct($config); 
    }
    /**
     * Get all enabled category
     * 
     * @param array $condition
     * @param string|array $order
     * @param int $count
     * @param int $offset
     * @return array
     */
    public function getAllEnabledCategory($condition = array(), $order = null, $count = null, $offset = null) {
    	   $select = $this->select()
    	   		   ->where('enabled = 1')
                   ->order($order)
                   ->limit($count, $offset);
                   
           return $this->fetchAll($select)->toArray();
    }
    
    public function getCategoryById($id)
    {
    	return current($this->find($id)->toArray());
    }
}